{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "import sys\n",
    "sys.path.append('/path/to/your/project/')\n",
    "\n",
    "import shutil\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "\n",
    "from pathlib import Path\n",
    "from tqdm import tqdm\n",
    "from importlib import reload"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CAMEO2022"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from src.analysis import cameo2022, single_ref, struct_align, struct_diversity, struct_quality\n",
    "reload(struct_diversity)\n",
    "reload(struct_align)\n",
    "reload(struct_quality)\n",
    "reload(single_ref)\n",
    "reload(cameo2022)\n",
    "\n",
    "results = cameo2022.eval_cameo2022(\n",
    "    result_root={\n",
    "        'exp1': '/path/to//generated/cameo/samples',\n",
    "\n",
    "    },\n",
    "    metadata_csv_path='/path/to/cameo2022_metadata.csv',\n",
    "    ref_root='/path/to/cameo2022/pdb',\n",
    "    num_samples=5, \n",
    "    n_proc=32,\n",
    "    tmscore_exec='tools/TMscore',\n",
    "    lddt_exec='tools/lddt'\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "results['report_tab']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Apo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from src import analysis\n",
    "reload(analysis)\n",
    "from src.analysis import apo, dual_ref, struct_align, struct_diversity, struct_quality\n",
    "reload(struct_diversity)\n",
    "reload(struct_align)\n",
    "reload(struct_quality)\n",
    "reload(dual_ref)\n",
    "reload(apo)\n",
    "\n",
    "results = apo.eval_apo(\n",
    "    result_root={\n",
    "        'exp1': '/path/to/apo/samples',\n",
    "        'exp2': '/another/path/to/apo/samples',\n",
    "    },\n",
    "    metadata_csv_path='/path/to/apo_metadata.csv',\n",
    "    ref_root='/path/to/apo/pdb',\n",
    "    num_samples=20,\n",
    "    n_proc=32,\n",
    "    return_all=True,\n",
    "    tmscore_exec='tools/TMscore',\n",
    ")\n",
    "results['report_tab']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "results['exp1']['align_scores']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "reload(dual_ref)\n",
    "reload(apo)\n",
    "apo.scatterplot_TMscore_ref1_vs_ref2(results['exp1'], chain_name='1BV2_2_A')\n",
    "apo.scatterplot_TMens_vs_TMref12(results['exp1'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Fast-folding"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from src.analysis import fastfold\n",
    "reload(fastfold)\n",
    "\n",
    "results = fastfold.eval_fastfold(\n",
    "    result_root={\n",
    "        'exp1': '/mnt/bn/lhwang-aidrug/outputs/eval/fast_folding/2024-08-26_20-29-29/test_gen',\n",
    "        # 'exp2': '/mnt/bn/lhwang-aidrug/outputs/full_atom/2024-05-09_13-24-07/test_gen/cameo2022',\n",
    "    },\n",
    "    metadata_csv_path='/mnt/bn/ailab-gdd-lq/csvs/fastfold.csv',\n",
    "    ref_root='/mnt/bn/yiqun-hmr/ConfRover/data/fast_folding/fullmd_ref_value/',\n",
    "    num_samples=1000,\n",
    "    n_proc=1,\n",
    "    tmscore_exec='tools/TMscore',\n",
    ")\n",
    "results['report_tab']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# BPTI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from datasets.bpti import analysis\n",
    "reload(analysis)\n",
    "from src.analysis import bpti\n",
    "reload(bpti)\n",
    "\n",
    "results = bpti.eval_bpti(\n",
    "    result_root={\n",
    "        'exp1': '/path/to/your/bpti/samples',\n",
    "    },\n",
    "    dataset_root='path/to/your/bpti',\n",
    "    metastates_pdb_root='path/to/your/bpti/metastates',\n",
    "    num_samples=1000,\n",
    "    n_proc=1,\n",
    "    tmscore_exec='tools/TMscore',\n",
    ")\n",
    "results['report_tab']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "results['exp1']['metrics']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ATLAS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!python3 -m datasets.atlas.analysis_aflow \\\n",
    "    --result-dir /path/to/atlas_test/ \\\n",
    "    --n-proc 4 # number of parallel workers. \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datasets.atlas.analysis_aflow as atlas\n",
    "\n",
    "aflow_result = atlas.report_analysis(\n",
    "    result_root={\n",
    "        'exp1': '/path/to/generated/atlas/',\n",
    "        'exp2': '/path/to/generated/atlas/',\n",
    "        ...\n",
    "    }\n",
    ")\n",
    "\n",
    "report_tab = atlas.format_table(\n",
    "    aflow_result['report_tab'], \n",
    ")\n",
    "\n",
    "report_tab"
   ]
  }
 ],
 "metadata": {
  "fileId": "44041d47-e24b-40f5-b706-74a13c4552b7",
  "filePath": "/root/wy/ConfRover/notebooks/analysis.ipynb",
  "kernelspec": {
   "display_name": "confrover",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.19"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
